﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;
using DemoLib.Data.Repositories;
using DemoLib.Shared.Contracts;
using DemoLib.Shared.Models;

namespace DemoLib.Service.Services
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
    public class UserService : IUserService
    {
        private readonly UserRepository _userRepository;
        public UserService()
        {
            _userRepository = new UserRepository();
        }

        public User GetUserById(int id)
        {
            return _userRepository.GetUserById(id);
        }

        public User ValidateUser(string userName, string password)
        {
            return _userRepository.VarifyUser(userName, password);
        }

        public IEnumerable<Role> GetRoles()
        {
            return _userRepository.GetRoles();
        }

        public void Register(RegisterUser registerUser)
        {
            _userRepository.Register(registerUser, 1);
        }

        public void UpdateUser(User user)
        {
            throw new NotImplementedException();
        }

        public bool ChangePassword(int userid, string oldPassword, string newPassword)
        {
            throw new NotImplementedException();
        }
    }
}
